package hy.controller;

import hy.beans.Person;
import hy.beans.YMLFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;

@RestController
public class MyCtrl {
    @Autowired
    Person p;

    @Autowired
    Environment env;
    @Autowired
    YMLFactory y;

    @RequestMapping("/test")
    public String m()throws Exception{
        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("person.birth"));
        p.setName(env.getProperty("person.name"));
        p.setBirth(new SimpleDateFormat("yyyy/MM/dd").parse(env.getProperty("person.birth")));
        return y.toString();
    }
}
